<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<!-- 搜书功能页面。 搜书功能页面。 搜书功能页面。 搜书功能页面。 -->
<html>
<head>
<title>'searchnovel.jsp'</title>

<style type="text/css">
td {
	text-align: center;
}
</style>

<script type="text/javascript"
	src="${pageContext.request.contextPath}/JS/toDoXHR.js"></script>


<script type="text/javascript">
	function howtoaction(act) {
		sel = document.getElementById("sel");
		key = document.getElementById("key");
		mode = sel.value;
		keyword = key.value;//以上得到搜索模式和关键字

		//保存关键字在这个页面中
		document.getElementById("modeDone").value = mode;
		document.getElementById("keywordSent").value = keyword;

		var url = "${pageContext.request.contextPath }/SearchNovelServlet";

		var params = "mode=" + mode + "&keyword=" + keyword + "&pagenum=1"
				+ "&type=" + act;
		toDoXHR(url, "POST", params, "tips");
	}
</script>
<script type="text/javascript">
	function toPage(num) {
		var old = document.getElementById("params").value;
		var params = old + "&pagenum=" + num;
		var url = "${pageContext.request.contextPath }/SearchNovelServlet";
		toDoXHR(url, "POST", params, "tips");
	}

	function goTo() {
		var num = document.getElementById("goPage").value;
		var pages = document.getElementById("pages").value;
		regex = /^\d+$/;
		patt1 = new RegExp(regex);
		if (!patt1.test(num)) {
			alert("输入正整数");
			return;
		}
		if (num > pages) {
			alert("超出范围");
			return;
		}
		toPage(num);
	}
</script>
<body>

	<div align="center">
		<table>
			<tr>
				<td><select id="sel" name="mode">
						<option value="novelname">小说名</option>
						<option value="authorname">作者</option>
				</select></td>
				<td><input id="key" type="text" name="keyword"></td>
			<tr>
			<tr>
				<td><input type="button" value="精确查找"
					onclick="howtoaction('accurate')" />
				</td>
				<td><input type="button" value="模糊查找"
					onclick="howtoaction('vague')" />
				</td>
			</tr>
		</table>


	</div>
	<div>
		<input type="hidden" id="modeDone" /> <input type="hidden"
			id="keywordSent" />

	</div>
	<div id="tips" align="center"></div>
</body>
</html>
